<template>
    <div id="info">
        <van-cell-group inset class="mt20">
            <van-field v-model="userInfo.alipay" center input-align="right" label="支付宝账户" placeholder="请输入支付宝账户" />
            <van-field v-model="userInfo.alipay_name" center input-align="right" label="支付宝姓名" placeholder="请输入支付宝开户人姓名" />
        </van-cell-group>
        <van-cell-group inset class="mt20">
            <van-field v-model="userInfo.bank_name" center input-align="right" label="银行名称" placeholder="请输入开户行名称" />
            <van-field v-model="userInfo.bank_no" center input-align="right" label="银行卡号" placeholder="请输入银行卡号" />
            <van-field v-model="userInfo.bank_person" center input-align="right" label="开户姓名" placeholder="请确认开户人姓名" />
        </van-cell-group>
        <div class="fixed-bottom">
            <div class="btn-1 btn-1-main" @click="submitWithdraw()">确认修改</div>
        </div>
    </div>
</template>


<script>
import { showToast } from 'vant';
export default {
    name: 'Info',
    data() {
        return {
            userInfo: {
                alipay: '',
                alipay_name: '',
                bank_name:'',
                bank_no:'',
                bank_person:'',
            },
        }
    },
    created() {
        this.$api.user.withdrawinfo({}).then(res => {
            this.userInfo = {
                alipay: res.result.alipay,
                alipay_name: res.result.alipay_name,
                bank_name:res.result.bank_name,
                bank_person:res.result.bank_person,
                bank_no:res.result.bank_no,
            };
        });
    },
    methods: {
        submitWithdraw(){
            let that = this;
            let params = that.userInfo;
            that.$api.user.withdraw(params).then(res => {
                showToast({
                    message:'修改成功',
                    overlay:true,
                    forbidClick:true,
                });
            }).finally(e => {});
        },
    }
}
</script>
